package main.java.com.zxl.jmx;

import javax.management.*;
import java.lang.management.ManagementFactory;

public class HelloAgent {

    /**
     * 亲测，确实可以通过jconsole调用HelloMBean的方法与设置属性
     * @param args
     * @throws MalformedObjectNameException
     * @throws NotCompliantMBeanException
     * @throws InstanceAlreadyExistsException
     * @throws MBeanRegistrationException
     * @throws InterruptedException
     */
    public static void main(String[] args) throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException, MBeanRegistrationException, InterruptedException {
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        ObjectName name=new ObjectName("jmxBean:name=hello");
        server.registerMBean(new Hello(),name);
        Thread.sleep(60*60*1000);
    }
}
